# **********************************************************************
#
# PS-Script: Export-groups
# 
# Author: Ruben
# Date:   2015-01-13
# Version: 1
#
# Description:
# This script exports groups from Active Directory except those
# in the builtin containers.
#
# Attention: 
# This PS script comes with ABSOLUTELY NO WARRANTY; for details
# see gnu-gpl. This is free software, and you are welcome
# to redistribute it under certain conditions; see gnu-gpl for details.
# 
# **********************************************************************


$rtnList = New-Object System.Collections.ArrayList

Get-ADGroup -Filter * -SearchScope Subtree | ForEach-Object {
    if (($_.DistinguishedName -notlike "*users,dc=*") -and ($_.DistinguishedName -notlike "*builtin,dc=*")) {
         $rtnList.Add($_.DistinguishedName + '^' + $_.Name)
    }
}

$rtnList | Out-File C:\ScheduledTasks\sact\allADGroups.txt -Encoding unicode